home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / ddj0492.zip / DFLT11.ZIP / COMBOBOX.C < prev    next >
Text File  |  1992-01-25  |  3KB  |  107 lines

  1. /* -------------- combobox.c -------------- */
  2.  
  3. #include "dflat.h"
  4.  
  5. int ListProc(WINDOW, MESSAGE, PARAM, PARAM);
  6.  
  7. int ComboProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
  8. {
  9.     switch (msg)    {
  10.         case CREATE_WINDOW:
  11.             wnd->extension = CreateWindow(LISTBOX,
  12.                                             NULL,
  13.                                             wnd->rc.lf,wnd->rc.tp+1,
  14.                                             wnd->ht-1, wnd->wd+1,
  15.                                             NULL,
  16.                                             GetParent(wnd),
  17.                                             ListProc,
  18.                                             HASBORDER | NOCLIP | SAVESELF);
  19.             ((WINDOW)(wnd->extension))->ct->command = wnd->ct->command;
  20.             wnd->ht = 1;
  21.             wnd->rc.bt = wnd->rc.tp;
  22.             break;
  23.         case PAINT:
  24.             foreground = FrameForeground(wnd);
  25.             background = FrameBackground(wnd);
  26.             wputch(wnd, DOWNSCROLLBOX, WindowWidth(wnd), 0);
  27.             break;
  28.         case KEYBOARD:
  29.             if ((int)p1 == DN)    {
  30.                 SendMessage(wnd->extension, SETFOCUS, TRUE, 0);
  31.                 return TRUE;
  32.             }
  33.             break;
  34.         case LEFT_BUTTON:
  35.             if ((int)p1 == GetRight(wnd) + 1)
  36.                 SendMessage(wnd->extension, SETFOCUS, TRUE, 0);
  37.             break;
  38.         default:
  39.             break;
  40.     }
  41.     return BaseWndProc(COMBOBOX, wnd, msg, p1, p2);
  42. }
  43.  
  44. int ListProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
  45. {
  46.     DBOX *db = GetParent(wnd)->extension;
  47.     WINDOW cwnd = ControlWindow(db, wnd->ct->command);
  48.     char text[130];
  49.     int rtn;
  50.     WINDOW currFocus;
  51.  
  52.     switch (msg)    {
  53.         case CREATE_WINDOW:
  54.             wnd->ct = malloc(sizeof(CTLWINDOW));
  55.             wnd->ct->setting = OFF;
  56.             break;
  57.         case SETFOCUS:
  58.             if ((int)p1 == FALSE)    {
  59.                 SendMessage(wnd, HIDE_WINDOW, 0, 0);
  60.                 wnd->ct->setting = OFF;
  61.             }
  62.             else 
  63.                 wnd->ct->setting = ON;
  64.             break;
  65.         case SHOW_WINDOW:
  66.             if (wnd->ct->setting == OFF)
  67.                 return TRUE;
  68.             break;
  69.         case BORDER:
  70.             currFocus = inFocus;
  71.             inFocus = NULL;
  72.             rtn = DefaultWndProc(wnd, msg, p1, p2);
  73.             inFocus = currFocus;
  74.             return rtn;
  75.         case LB_SELECTION:
  76.             rtn = DefaultWndProc(wnd, msg, p1, p2);
  77.             SendMessage(wnd, LB_GETTEXT, (PARAM) text, wnd->selection);
  78.             PutItemText(GetParent(wnd), wnd->ct->command, text);
  79.             SendMessage(cwnd, PAINT, 0, 0);
  80.             cwnd->TextChanged = TRUE;
  81.             return rtn;
  82.         case KEYBOARD:
  83.             switch ((int) p1)    {
  84.                 case ESC:
  85.                 case FWD:
  86.                 case BS:
  87.                     SendMessage(cwnd, SETFOCUS, TRUE, 0);
  88.                     return TRUE;
  89.                 default:
  90.                     break;
  91.             }
  92.             break;
  93.         case LB_CHOOSE:
  94.             SendMessage(cwnd, SETFOCUS, TRUE, 0);
  95.             return TRUE;
  96.         case CLOSE_WINDOW:
  97.             if (wnd->ct != NULL)
  98.                 free(wnd->ct);
  99.             break;
  100.         default:
  101.             break;
  102.     }
  103.     return DefaultWndProc(wnd, msg, p1, p2);
  104. }
  105.  
  106.  
  107.